package com.example.hyxydoctor.base;

import android.app.Application;

public class App {
        public static final Application INSTANCE;

        static {
            Application app = null;
            try {
                app = (Application) Class.forName("android.app.AppGlobals").getMethod("getInitialApplication").invoke(null);
                if (app == null)
                    throw new IllegalStateException("Static initialization of Applications must be on main thread.");
            } catch (final Exception e) {
                System.out.println("Failed to get current application from AppGlobals." + e.getMessage());
                try {
                    app = (Application) Class.forName("android.app.ActivityThread").getMethod("currentApplication").invoke(null);
                } catch (final Exception ex) {
                    System.out.println("Failed to get current application from ActivityThread." + e.getMessage());
                }
            } finally {
                INSTANCE = app;
            }
        }
    }

